<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>打印三角形</title>
</head>

<body>
    <script>
        var n = prompt('请输入行数');
        for (var i = 1; i <= n; i++) {
            for (var j = 1; j <= i; j++) {
                document.write("*");

            }
            for (var j = 1; j <= n - i; j++) {
                document.write("&nbsp;");

            }
            document.write('</br>');
        }
    </script>
</body>

</html>